<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/share/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>提现记录</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<%@ include file="/WEB-INF/share/wechat.jsp"%>
</head>
<body>
	<%@ include file="/WEB-INF/share/wechattop.jsp"%>
	<div class="mui-content">
    		<div id="pullrefresh" class="mui-content mui-scroll-wrapper" style="margin-top:38px;padding-bottom: 50px;">
			  <div class="mui-scroll">
			    <!--数据列表-->
			    <ul class="mui-table-view mui-table-view-chevron">
			    </ul>
			  </div>
			  <div style="width: 100%;height:50px"></div>
			</div>
	</div>
	<%@ include file="/WEB-INF/share/wechatscript.jsp"%>
	<script>
			var url="${ctx}/wx/applylistdata";
			mui.init({
	            swipeBack: false,
	            pullRefresh: {
	                container: '#pullrefresh',
	                down: {
	                	 auto:true,//可选,默认false.自动下拉刷新一次
			             contentdown : "下拉可以刷新",//可选，在下拉可刷新状态时，下拉刷新控件上显示的标题内容
			             contentover : "释放立即刷新",//可选，在释放可刷新状态时，下拉刷新控件上显示的标题内容
			             contentrefresh : "正在刷新...",//可选，正在刷新状态时，下拉刷新控件上显示的标题内容
			             callback: pulldownRefresh
	                },
			        up: {
			            //auto:true,//可选,默认false.自动上拉加载一次
			            contentrefresh: '正在加载...',
			            contentnomore:'没有更多数据了',//可选，请求完毕若没有更多数据时显示的提醒内容；
			            callback: pullupRefresh
			        }
	            }
	        });
			var downstatus=0;
			function pulldownRefresh() {
				if(downstatus==0){
				  setTimeout(function() {
				        count = 1;
				        data={
				           page:count
				        };
				        type=1;//代表下拉刷新
				        toList(data,type);//具体取数据的方法
				    }, 100);
				  downstatus=1;
				}else{
					window.location.reload();
				}
			}
			function pullupRefresh() {
			    setTimeout(function() {
			        count++;//翻下一页
			        data={
			            page:count
			        };
			        type=2;//代表上拉加载
			        toList(data,type);//具体取数据的方法
			    }, 100);
			}
			if(mui.os.plus) {
			    mui.plusReady(function() {
			        setTimeout(function() {
			            mui('#pullrefresh').pullRefresh().pulldownLoading();
			        }, 500);
			    });
			} else {
			    mui.ready(function() {
			        mui('#pullrefresh').pullRefresh().pulldownLoading();
			    });
			}
			var toList = function(dataval,type) {
				 var table = document.body.querySelector('.mui-table-view');
	             var cells = document.body.querySelectorAll('.mui-table-view-cell');
				 mui.ajax(url, {
				        data:dataval,
				        dataType: 'json',
				        type: 'POST',
				        timeout: 10000,
				        success: function(data) {
				        	if(type==1){
				        		$.each(data, function(i, n){
				        			var li = document.createElement('li');
		                            li.className = 'mui-table-view-cell';
		                            var info="金额:";
		                            var href="#"
		                            if(n.withtype==1){
		                            	var sktype="支付宝:"+n.account;
		                            }else{
		                            	var sktype="微信:"+n.account;
		                            }
		                            if(n.status==1){
		                            	var status="已提交";
		                            }
		                            if(n.status==2){
		                            	var status="已打款";
		                            }
		                            if(n.status==3){
		                            	var status="已退回";
		                            }
		                            if (n.name == null){
		                            	var bak='';
		                            }else{
		                            	var bak='(备注:'+n.name+')';
		                            }
		                            li.innerHTML = '<a class="mui-navigate-right" href='+href+'>'+info+ n.money+'('+sktype+')'+'状态:'+status+bak+'</a>';
		                    		//下拉刷新，新纪录插到最前面；
		                   			 table.insertBefore(li, table.firstChild);
		                         });  
				        	  	 mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
				        	}
							if(type==2){
								$.each(data, function(i, n){
									var li = document.createElement('li');
		                            li.className = 'mui-table-view-cell';
		                            var info="金额:";
		                            var href="#"
		                            if(n.withtype==1){
		                            	var sktype="支付宝:"+n.account;
		                            }else{
		                            	var sktype="微信:"+n.account;
		                            }
		                            if(n.status==1){
		                            	var status="已提交";
		                            }
		                            if(n.status==2){
		                            	var status="已打款";
		                            }
		                            if(n.status==3){
		                            	var status="已退回";
		                            }
		                            if (n.name == null){
		                            	var bak='';
		                            }else{
		                            	var bak='(备注:'+n.name+')';
		                            }
		                            li.innerHTML = '<a class="mui-navigate-right" href='+href+'>'+info+ n.money+'('+sktype+')'+'状态:'+status+bak+'</a>';
		                    		//下拉刷新，新纪录插到最前面；
		                   			 table.insertBefore(li, table.firstChild);
		                         });  
				        	  	 mui('#pullrefresh').pullRefresh().endPullupToRefresh();
				        	}
				        },
				        error: function(xhr, type, errerThrown) {
				            mui.toast('网络异常,请稍候再试');
				            mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
				        }
				});
			};
		
		</script>
</body>
</html>
